faApp.controller('IndexCtrl',['$scope','userService','$location','$controller','$rootScope','$timeout',function($scope,userService,$location,$controller,$rootScope,$timeout) {   
	$controller('BaseCtrl', {$scope: $scope}); 

  $scope.nav = {"module":"product"};

  $scope.changeNavModule = function(v){
    $scope.nav.module = v;
  }; 
  $scope.checkLoginStatus();

  $timeout(function(){
    $scope.changeNavModule($("#J_tmenu li:first").attr("who"));
  },300);

}]); 

faApp.controller('IndexPanelCtrl',['$scope','userService','$location','$controller','$rootScope','operationService','$filter',function($scope,userService,$location,$controller,$rootScope,operationService,$filter) {   
	$controller('BaseCtrl', {$scope: $scope}); 

  $scope.openPage = function(url,title,id){
    var data = {url:url,id:id,title:title};
    $scope.$emit("pageopen",data);
  }; 

  if ($scope.hasAuth("btn","OPERATION_STAT_COUNT")){
    var t = (new Date()).getTime();
    operationService.statCount({countDateBeginStr:$filter('date')(t - 86400000 * 7,'yyyy-MM-dd'),countDateEndStr:$filter('date')(t - 86400000,'yyyy-MM-dd')}).then(function(json){
      $scope.statData = json;  
    });
  }
}]);
faApp.controller('IndexEverydayCtrl',['$scope','userService','$location','$controller','$rootScope','operationService','$filter','ajaxService',function($scope,userService,$location,$controller,$rootScope,operationService,$filter,ajaxService) {
  $controller('BaseCtrl', {$scope: $scope});
  console.info('IndexEverydayCtrl');
  //我的业绩,团队业绩
  operationService.queryOrderOwnerUserCountAmount().then(function(json){
    console.info('我的业绩,团队业绩');
    console.log(json);
    $scope.resultstData = json;
  });
  //用户访问详情
  operationService.queryVistDetail().then(function(json){
    console.info('用户访问详情');
    console.log(json);
    $scope.visData = json;
  });
  //待办事项列表
  function getlistFaRevisitTask(){
    operationService.listFaRevisitTask({
      faRevisitType:'2'
    }).then(function(json){
      console.info('待办事项列表');
      console.log(json);
      $scope.taskData = json.list;
    });
  }
  getlistFaRevisitTask();
  //关注客户
  operationService.customerFocus().then(function(json){
    console.info('关注客户');
    console.log(json);
    $scope.cfData = json.list;
  });
  //标记已完成faRevisitTask/updateFaRevisitTask.shtml
  $scope.ckupTask = function(id){
    console.info('标记已完成');
    operationService.updateFaRevisitTask({
      id:id
    }).then(function(json){
      console.info('标记已完成');
      getlistFaRevisitTask();
    });
  };

}]);